1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module sourceview.CompletionProviderT; 26 27 public import gio.AsyncResultIF; 28 public import gio.Cancellable; 29 public import gio.ListModelIF; 30 public import glib.ErrorG; 31 public import glib.GException; 32 public import glib.PtrArray; 33 public import glib.Str; 34 public import glib.c.functions; 35 public import gobject.ObjectG; 36 public import gtk.TextIter; 37 public import sourceview.CompletionCell; 38 public import sourceview.CompletionContext; 39 public import sourceview.CompletionProposalIF; 40 public import sourceview.c.functions; 41 public import sourceview.c.types; 42 43 44 /** 45 * Completion provider interface. 46 * 47 * You must implement this interface to provide proposals to [class@Completion]. 48 * 49 * In most cases, implementations of this interface will want to use 50 * [vfunc@CompletionProvider.populate_async] to asynchronously populate the results 51 * to avoid blocking the main loop. 52 */ 53 public template CompletionProviderT(TStruct) 54 { 55 /** Get the main Gtk struct */ 56 public GtkSourceCompletionProvider* getCompletionProviderStruct(bool transferOwnership = false) 57 { 58 if (transferOwnership) 59 ownedRef = false; 60 return cast(GtkSourceCompletionProvider*)getStruct(); 61 } 62 63 64 /** 65 * This function requests @proposal to be activated by the 66 * #GtkSourceCompletionProvider. 67 * 68 * What the provider does to activate the proposal is specific to that 69 * provider. Many providers may choose to insert a #GtkSourceSnippet with 70 * edit points the user may cycle through. 71 * 72 * See also: [class@Snippet], [class@SnippetChunk], [method@View.push_snippet] 73 * 74 * Params: 75 * context = a #GtkSourceCompletionContext 76 * proposal = a #GtkSourceCompletionProposal 77 */ 78 public void activate(CompletionContext context, CompletionProposalIF proposal) 79 { 80 gtk_source_completion_provider_activate(getCompletionProviderStruct(), (context is null) ? null : context.getCompletionContextStruct(), (proposal is null) ? null : proposal.getCompletionProposalStruct()); 81 } 82 83 /** 84 * This function requests that the #GtkSourceCompletionProvider prepares 85 * @cell to display the contents of @proposal. 86 * 87 * Based on @cells column type, you may want to display different information. 88 * 89 * This allows for columns of information among completion proposals 90 * resulting in better alignment of similar content (icons, return types, 91 * method names, and parameter lists). 92 * 93 * Params: 94 * context = a #GtkSourceCompletionContext 95 * proposal = a #GtkSourceCompletionProposal 96 * cell = a #GtkSourceCompletionCell 97 */ 98 public void display(CompletionContext context, CompletionProposalIF proposal, CompletionCell cell) 99 { 100 gtk_source_completion_provider_display(getCompletionProviderStruct(), (context is null) ? null : context.getCompletionContextStruct(), (proposal is null) ? null : proposal.getCompletionProposalStruct(), (cell is null) ? null : cell.getCompletionCellStruct()); 101 } 102 103 /** 104 * This function should return the priority of @self in @context. 105 * 106 * The priority is used to sort groups of completion proposals by 107 * provider so that higher priority providers results are shown 108 * above lower priority providers. 109 * 110 * Lower value indicates higher priority. 111 * 112 * Params: 113 * context = a #GtkSourceCompletionContext 114 */ 115 public int getPriority(CompletionContext context) 116 { 117 return gtk_source_completion_provider_get_priority(getCompletionProviderStruct(), (context is null) ? null : context.getCompletionContextStruct()); 118 } 119 120 /** 121 * Gets the title of the completion provider, if any. 122 * 123 * Currently, titles are not displayed in the completion results, but may be 124 * at some point in the future when non-%NULL. 125 * 126 * Returns: a title for the provider or %NULL 127 */ 128 public string getTitle() 129 { 130 auto retStr = gtk_source_completion_provider_get_title(getCompletionProviderStruct()); 131 132 scope(exit) Str.freeString(retStr); 133 return Str.toString(retStr); 134 } 135 136 /** 137 * This function is used to determine of a character inserted into the text 138 * editor should cause a new completion request to be triggered. 139 * 140 * An example would be period '.' which might indicate that the user wants 141 * to complete method or field names of an object. 142 * 143 * Params: 144 * iter = a #GtkTextIter 145 * ch = a #gunichar of the character inserted 146 */ 147 public bool isTrigger(TextIter iter, dchar ch) 148 { 149 return gtk_source_completion_provider_is_trigger(getCompletionProviderStruct(), (iter is null) ? null : iter.getTextIterStruct(), ch) != 0; 150 } 151 152 /** 153 * This function is used to determine if a key typed by the user should 154 * activate @proposal (resulting in committing the text to the editor). 155 * 156 * This is useful when using languages where convention may lead to less 157 * typing by the user. One example may be the use of "." or "-" to expand 158 * a field access in the C programming language. 159 * 160 * Params: 161 * context = a #GtkSourceCompletionContext 162 * proposal = a #GtkSourceCompletionProposal 163 * keyval = a keyval such as [const@Gdk.KEY_period] 164 * state = a #GdkModifierType or 0 165 */ 166 public bool keyActivates(CompletionContext context, CompletionProposalIF proposal, uint keyval, GdkModifierType state) 167 { 168 return gtk_source_completion_provider_key_activates(getCompletionProviderStruct(), (context is null) ? null : context.getCompletionContextStruct(), (proposal is null) ? null : proposal.getCompletionProposalStruct(), keyval, state) != 0; 169 } 170 171 /** 172 * Providers should return a list of alternates to @proposal or %NULL if 173 * there are no alternates available. 174 * 175 * This can be used by the completion view to allow the user to move laterally 176 * through similar proposals, such as overrides of methods by the same name. 177 * 178 * Params: 179 * context = a #GtkSourceCompletionContext 180 * proposal = a #GtkSourceCompletionProposal 181 * 182 * Returns: a #GPtrArray of #GtkSourceCompletionProposal or %NULL. 183 */ 184 public PtrArray listAlternates(CompletionContext context, CompletionProposalIF proposal) 185 { 186 auto __p = gtk_source_completion_provider_list_alternates(getCompletionProviderStruct(), (context is null) ? null : context.getCompletionContextStruct(), (proposal is null) ? null : proposal.getCompletionProposalStruct()); 187 188 if(__p is null) 189 { 190 return null; 191 } 192 193 return new PtrArray(cast(GPtrArray*) __p, true); 194 } 195 196 /** 197 * Asynchronously requests that the provider populates the completion 198 * results for @context. 199 * 200 * For providers that would like to populate a [iface@Gio.ListModel] while those 201 * results are displayed to the user, 202 * [method@CompletionContext.set_proposals_for_provider] may be used 203 * to reduce latency until the user sees results. 204 * 205 * Params: 206 * context = a #GtkSourceCompletionContext 207 * cancellable = a #GCancellable or %NULL 208 * callback = a callback to execute upon completion 209 * userData = closure data for @callback 210 */ 211 public void populateAsync(CompletionContext context, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 212 { 213 gtk_source_completion_provider_populate_async(getCompletionProviderStruct(), (context is null) ? null : context.getCompletionContextStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 214 } 215 216 /** 217 * Completes an asynchronous operation to populate a completion provider. 218 * 219 * Params: 220 * result = a #GAsyncResult provided to callback 221 * 222 * Returns: a #GListModel of #GtkSourceCompletionProposal 223 * 224 * Throws: GException on failure. 225 */ 226 public ListModelIF populateFinish(AsyncResultIF result) 227 { 228 GError* err = null; 229 230 auto __p = gtk_source_completion_provider_populate_finish(getCompletionProviderStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err); 231 232 if (err !is null) 233 { 234 throw new GException( new ErrorG(err) ); 235 } 236 237 if(__p is null) 238 { 239 return null; 240 } 241 242 return ObjectG.getDObject!(ListModelIF)(cast(GListModel*) __p, true); 243 } 244 245 /** 246 * This function can be used to filter results previously provided to 247 * the [class@CompletionContext] by the #GtkSourceCompletionProvider. 248 * 249 * This can happen as the user types additional text onto the word so 250 * that previously matched items may be removed from the list instead of 251 * generating new [iface@Gio.ListModel] of results. 252 * 253 * Params: 254 * context = a #GtkSourceCompletionContext 255 * model = a #GListModel 256 */ 257 public void refilter(CompletionContext context, ListModelIF model) 258 { 259 gtk_source_completion_provider_refilter(getCompletionProviderStruct(), (context is null) ? null : context.getCompletionContextStruct(), (model is null) ? null : model.getListModelStruct()); 260 } 261 }